package com.zc.redisson.stream.service;


import com.alibaba.fastjson2.JSONObject;
import com.zc.domain.ElectricAlarm;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * redis stream监听消息
 */
@Component
public class ElectricAlarmService {

    private final Logger logger = LoggerFactory.getLogger(ElectricAlarmService.class);

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private RedissonClient redissonClient;


    public void onMessage(Map<String, ElectricAlarm> valueMap) {
        try {
            // 接收到消息
            JSONObject jsonObject = new JSONObject();
            jsonObject.putAll(valueMap);
            logger.info("指标阈值告警消息内容:{}",valueMap);
        } catch (Exception e) {
            logger.error("指标阈值告警处理异常", e);
        }
    }


}
